DIBadMount
DIBadMount Process a disk insert event that caused an error
#include <DiskInit.h> Disk Initialization Package
short DIBadMount( globalPt, evtMessage );
Point globalPt ; top-left corner of DI dialog (global coordinates)
long evtMessage ; message field of a EventRecord
returns an Error Code; 0=no error
You can call DIBadMount when a call to GetNextEvent returns a diskEvt
event and the returned message indicates an error (the high word is
non-zero). It draws a dialog and (if the user OKs it) formats the disk and sets
up an empty directory, block map, and volume information.
globalPt is a Point, expressed in global ( screen) coordinates. It identifies
where you want to put the top left corner of the "Do you want to
initialize it" dialog displayed by DIBadMount.
evtMessage is a 32-bit code. The low word identifies the drive on which you
want to format a disk. The high word is an OSErr code as returned
from PBMountVol (e.g., ioErr, noMacDskErr, etc.).
This parameter matches the message field of an EventRecord
returned by GetNextEvent when the what field has been set to
diskEvt.
Returns: an integer result code. Negative values are OSErr codes. It will be
one of:
(2) There is a mounted volume in the drive
(1) User clicked Eject in DI dialog
noErr (0) No error
extFSErr (-58) External file system
memFulErr (-108) Not enough room in heap
nsDrvErr (-56) No such drive
paramErr (-50) Bad drive number
volOnLinErr (-55) Drive volume already on-line
firstDskErr (-84) ... through ...
lastDskErr (-64) (low-level disk errors)

Notes: By the time you get a diskEvt back from GetNextEvent, the Event
Manager has already attempted to mount the volume. If you are using the
lower-level GetOSEvent, then you should attempt to mount it using
PBMountVol and check for an error before calling DIBadMount.
Most applications can simply ignore disk insertions. If you use Standard
File to get filenames, that package will take care of disk insertions,
ejections, and formatting. If you'd rather do it yourself, you can use the
following sequence:
Point diDlgPt;
short rc;
EventRecord theEvent;
GetNextEvent( everyEvent, & theEvent)
.
:
if ( theEvent.what == diskEvt ) {
if (( theEvent.message & 0xFFFF0000) != 0) {/*err mounting*/
SetPt( &diDlgPt, 100,100 );
rc = DIBadMount( diDlgPt, theEvent. message); /* do it */
if ( rc < 0 ) { ... some error occurred ... }
}
}